<?php
/**
 * base.php
 * User: yzm
 * Date: 2017/7/25
 */
abstract class WebBase extends Wherein_knowledgeModuleSite{
    public $modulename;
    public $module;
    public $weid;
    public $uniacid;
    public $__define;

    public function __construct() {
        $this->checkOrderStatus();
    }

    //设置私有属性值
    public function __set($name,$value){
        $this->{$name} = $value;
    }

    //输出模板
    protected function template($filename) {
        global $_W,$_GPC;
        $name = strtolower($this->modulename);
        $defineDir = dirname($this->__define);

        $source = IA_ROOT . "/web/themes/{$_W['template']}/{$name}/{$filename}.html";
        $compile = IA_ROOT . "/data/tpl/web/{$_W['template']}/{$name}/".$_GPC['do']."/{$filename}.tpl.php";
        if(!is_file($source)) {
            $source = IA_ROOT . "/web/themes/default/{$name}/{$filename}.html";
        }
        if(!is_file($source)) {
            $source = $defineDir . "/application/web/view/". $_GPC['do'] ."/{$filename}.html";
        }
        if(!is_file($source)) {
            $source = IA_ROOT . "/web/themes/{$_W['template']}/{$filename}.html";
        }
        /*if(!is_file($source)) {
            $source = IA_ROOT . "/web/themes/default/{$filename}.html";
        }*/
        if(!is_file($source)) {
            exit("Error: template source '{$filename}' is not exist!");
        }
        $paths = pathinfo($compile);
        $compile = str_replace($paths['filename'], $_W['uniacid'] . '_' . $paths['filename'], $compile);
        if (DEVELOPMENT || !is_file($compile) || filemtime($source) > filemtime($compile)) {
            template_compile($source, $compile, true);
        }
        return $compile;
    }

}